package org.example;

import org.gridgain.internal.h2.vector.MyVector;
import org.junit.Test;

import java.util.List;

public class MyVectorCase {

    @Test
    public void createVectorTable_case() throws Exception {
        String path = "/Users/chenfei/temp/";
        String tableName = "my_vector";

        MyVector myVector = new MyVector(path, tableName);
        myVector.createVectorTable(true);
    }

    @Test
    public void insertVector_case() throws Exception {
        String path = "/Users/chenfei/temp/";
        String tableName = "my_vector";

        MyVector myVector = new MyVector(path, tableName);
        myVector.insertVector("A", new Double[]{1.1, 2.2, 3.3});
        myVector.insertVector("B", new Double[]{1.2, 2.1, 3.5});
        myVector.insertVector("E", new Double[]{2.2, 3.1, 2.5});
        myVector.insertVector("C", new Double[]{10.1, 20.2, 30.3});
        myVector.insertVector("D", new Double[]{11.1, 19.2, 28.3});
    }

    @Test
    public void query_case() throws Exception {
        String path = "/Users/chenfei/temp/";
        String tableName = "my_vector";

        MyVector myVector = new MyVector(path, tableName);
        //Set<Object> rs = myVector.query(new Double[]{10.5, 18.2, 27.3}, 2);
        List<Object> rs = myVector.query(new Double[]{1.8, 1.9, 4.5}, 2);
        for (Object obj : rs)
        {
            System.out.println(obj);
        }
    }
}
